foldSuspend

inline suspend fun <R, T> Result<T>.foldSuspend(crossinline onSuccess: suspend (value: T) -> R, crossinline onFailure: suspend (exception: Throwable) -> R): R

Performs a fold operation on the Result, executing onSuccess if the Result is a success, or onFailure if the Result is a failure.

Return

Result of applying the corresponding function based on the current Result state.

Parameters

onSuccess

A suspend function to be executed on success.

onFailure

A suspend function to be executed on failure.